<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
      function Studance(name,age) {
      this.name = name;
      this.age = age;
      this.address = {
      city : "bj"
    }
      // this.type = "bus";
      // this.fuu = function () {
      //   console.log(this.name);
      // }
    }
    // 添加一个新的属性给原型对象，属性值为对象
    Studance.prototype.address = {
      city : "hk"
    }
    Studance.prototype.adds = {
      height : "288px"
    }
    Studance.prototype.type = "bbs";
    Studance.prototype.fan =  function () {
        console.log(this.age);
      }
        var st1 = new Studance("试试",115);
        var st2 = new Studance("自杀",112);
    st2.fan();
    // 读取属性和方法--优先读自身
    console.log(st1.type);
      console.log(st1.address.city);
      console.log(st1.sxx);
    
    
    // 通过实例对象添加成员会添加给自己，屏蔽原型对象的访问
    st2.sex = "nan";
    st2.sexx = function () {
        console.log(11);
    }
    console.log(st2);//有sex: "nan",sexx
    console.log(st1);//无sex: "nan"

    // 通过实例对象更改原型对象上的成员，会添加给自己，屏蔽原型对象的访问
    st1.type = "mdzz";
    st1.address = {
      city : "russie"
    }
    console.log(st1);

    // 通过实例对象更改对象中的复杂数据类型，会进行原型链的查找
    st1.adds.height ="200px"
    st1.address.city ="heb"
    // st1.as.city ="heb"
    console.log(st1);


    function Student(name,sex) {
      this.name = name;
      this.sex = sex;
      return "1111111111"
    }
    var ss1 = new Student("zhangsan","nv")
    console.log();
  </script>
</body>
</html>